package gold.enterprise;

import java.util.concurrent.atomic.AtomicInteger;

public class Sougou {


    public AtomicInteger count = new AtomicInteger(0);
    public static final int LIMIT = 10;

    /**
     * 说是一个生产者消费者模型
     */
    public void doExecute() throws Exception {
        System.out.println("start to execute doExecute method");
        while (count.get() > LIMIT) {
            synchronized (count) {
                count.wait();
            }
        }

        new Thread(
                new Runnable() {
                    @Override
                    public void run() {
                        count.incrementAndGet();
                        // 业务逻辑处理
                        count.decrementAndGet();
                        count.notifyAll();
                    }
                }
        ).start();
    }

}
